﻿#pragma once

#include <cstdint>
#include <string>

namespace TDesign::Theme
{
    namespace Light
    {
        enum class Colors : uint32_t
        {
            // Brand colors 主题色
            brand_color_1 = 0xF2F3FFFF,
            brand_color_2 = 0xD9E1FFFF,
            brand_color_3 = 0xB5C7FFFF,
            brand_color_4 = 0x8EABFFFF,
            brand_color_5 = 0x618DFFFF,
            brand_color_6 = 0x366EF4FF,
            brand_color_7 = 0x0052D9FF,
            brand_color_8 = 0x003CABFF,
            brand_color_9 = 0x002A7CFF,
            brand_color_10 = 0x001A57FF,

            // Warning colors 警告色
            warning_color_1 = 0xFFF1E9FF,
            warning_color_2 = 0xFFD9C2FF,
            warning_color_3 = 0xFFB98CFF,
            warning_color_4 = 0xFA9550FF,
            warning_color_5 = 0xE37318FF,
            warning_color_6 = 0xBE5A00FF,
            warning_color_7 = 0x954500FF,
            warning_color_8 = 0x713300FF,
            warning_color_9 = 0x532300FF,
            warning_color_10 = 0x3B1700FF,

            // Error colors 错误色
            error_color_1 = 0xFFF0EDFF,
            error_color_2 = 0xFFD8D2FF,
            error_color_3 = 0xFFB9B0FF,
            error_color_4 = 0xFF9285FF,
            error_color_5 = 0xF6685DFF,
            error_color_6 = 0xD54941FF,
            error_color_7 = 0xAD352FFF,
            error_color_8 = 0x881F1CFF,
            error_color_9 = 0x68070AFF,
            error_color_10 = 0x490002FF,

            // Success colors 成功色
            success_color_1 = 0xE3F9E9FF,
            success_color_2 = 0xC6F3D7FF,
            success_color_3 = 0x92DAB2FF,
            success_color_4 = 0x56C08DFF,
            success_color_5 = 0x2BA471FF,
            success_color_6 = 0x008858FF,
            success_color_7 = 0x006C45FF,
            success_color_8 = 0x005334FF,
            success_color_9 = 0x003B23FF,
            success_color_10 = 0x002515FF,

            // Gray colors 中性色
            gray_color_1 = 0xF3F3F3FF,
            gray_color_2 = 0xEEEEEEFF,
            gray_color_3 = 0xE8E8E8FF,
            gray_color_4 = 0xDDDDDDFF,
            gray_color_5 = 0xC6C6C6FF,
            gray_color_6 = 0xA6A6A6FF,
            gray_color_7 = 0x8B8B8BFF,
            gray_color_8 = 0x777777FF,
            gray_color_9 = 0x5E5E5EFF,
            gray_color_10 = 0x4B4B4BFF,
            gray_color_11 = 0x393939FF,
            gray_color_12 = 0x2C2C2CFF,
            gray_color_13 = 0x242424FF,
            gray_color_14 = 0x181818FF,

            // Font colors 字体颜色
            font_white_1 = 0xFFFFFFFF,
            font_white_2 = 0xFFFFFF8C,  // rgba(255,255,255,0.55)
            font_white_3 = 0xFFFFFF59,  // rgba(255,255,255,0.35)
            font_white_4 = 0xFFFFFF38,  // rgba(255,255,255,0.22)
            font_gray_1 = 0x000000E6,   // rgba(0,0,0,0.9)
            font_gray_2 = 0x00000099,   // rgba(0,0,0,0.6)
            font_gray_3 = 0x00000066,   // rgba(0,0,0,0.4)
            font_gray_4 = 0x00000042,   // rgba(0,0,0,0.26)

            // Semantic colors 颜色语义别名
            brand_color = brand_color_7,
            warning_color = warning_color_5,
            error_color = error_color_6,
            success_color = success_color_5,
            brand_color_hover = brand_color_6,
            brand_color_focus = brand_color_2,
            brand_color_active = brand_color_8,
            brand_color_disabled = brand_color_3,
            brand_color_light = brand_color_1,
            brand_color_light_hover = brand_color_2,
            warning_color_hover = warning_color_4,
            warning_color_focus = warning_color_2,
            warning_color_active = warning_color_6,
            warning_color_disabled = warning_color_3,
            warning_color_light = warning_color_1,
            warning_color_light_hover = warning_color_2,
            error_color_hover = error_color_5,
            error_color_focus = error_color_2,
            error_color_active = error_color_7,
            error_color_disabled = error_color_3,
            error_color_light = error_color_1,
            error_color_light_hover = error_color_2,
            success_color_hover = success_color_4,
            success_color_focus = success_color_2,
            success_color_active = success_color_6,
            success_color_disabled = success_color_3,
            success_color_light = success_color_1,
            success_color_light_hover = success_color_2,

            // UI colors
            mask_active = 0x00000099,       // rgba(0,0,0,0.6)
            mask_disabled = 0xFFFFFF99,     // rgba(255,255,255,0.6)
            bg_color_page = gray_color_2,
            bg_color_container = 0xFFFFFFFF,
            bg_color_container_hover = gray_color_1,
            bg_color_container_active = gray_color_3,
            bg_color_container_select = 0xFFFFFFFF,
            bg_color_secondary_container = gray_color_1,
            bg_color_secondary_container_hover = gray_color_2,
            bg_color_secondary_container_active = gray_color_4,
            bg_color_component = gray_color_3,
            bg_color_component_hover = gray_color_4,
            bg_color_component_active = gray_color_6,
            bg_color_secondary_component = gray_color_4,
            bg_color_secondary_component_hover = gray_color_5,
            bg_color_secondary_component_active = gray_color_6,
            bg_color_component_disabled = gray_color_2,
            bg_color_special_component = 0xFFFFFFFF,
            text_color_primary = font_gray_1,
            text_color_secondary = font_gray_2,
            text_color_placeholder = font_gray_3,
            text_color_disabled = font_gray_4,
            text_color_anti = 0xFFFFFFFF,
            text_color_brand = brand_color_7,
            text_color_link = brand_color_8,
            border_level_1_color = gray_color_3,
            component_stroke = gray_color_3,
            border_level_2_color = gray_color_4,
            component_border = gray_color_4,
            table_shadow_color = 0x00000014, // rgba(0,0,0,0.08)
            scrollbar_color = 0x0000001A,    // rgba(0,0,0,0.1)
            scrollbar_hover_color = 0x0000004D, // rgba(0,0,0,0.3)
            scroll_track_color = 0xFFFFFFFF
        };
    }

    namespace Dark
    {
        enum class Colors : uint32_t
        {
            // Brand colors
            brand_color_1 = 0xF2F3FFFF,
            brand_color_2 = 0xD9E1FFFF,
            brand_color_3 = 0x143975FF,
            brand_color_4 = 0x103D88FF,
            brand_color_5 = 0x0D429AFF,
            brand_color_6 = 0x054BBEFF,
            brand_color_7 = 0x2667D4FF,
            brand_color_8 = 0x4582E6FF,
            brand_color_9 = 0x699EF5FF,
            brand_color_10 = 0x96BBF8FF,

            // Warning colors
            warning_color_1 = 0x4F2A1DFF,
            warning_color_2 = 0x582F21FF,
            warning_color_3 = 0x733C23FF,
            warning_color_4 = 0xA75D2BFF,
            warning_color_5 = 0xCF6E2DFF,
            warning_color_6 = 0xDC7633FF,
            warning_color_7 = 0xE8935CFF,
            warning_color_8 = 0xECBF91FF,
            warning_color_9 = 0xEED7BFFF,
            warning_color_10 = 0xF3E9DCFF,

            // Error colors
            error_color_1 = 0x472324FF,
            error_color_2 = 0x5E2A2DFF,
            error_color_3 = 0x703439FF,
            error_color_4 = 0x83383EFF,
            error_color_5 = 0xA03F46FF,
            error_color_6 = 0xC64751FF,
            error_color_7 = 0xDE6670FF,
            error_color_8 = 0xEC888EFF,
            error_color_9 = 0xEDB1B6FF,
            error_color_10 = 0xEECED0FF,

            // Success colors
            success_color_1 = 0x193A2AFF,
            success_color_2 = 0x1A4230FF,
            success_color_3 = 0x17533DFF,
            success_color_4 = 0x0D7A55FF,
            success_color_5 = 0x059465FF,
            success_color_6 = 0x43AF8AFF,
            success_color_7 = 0x46BF96FF,
            success_color_8 = 0x80D2B6FF,
            success_color_9 = 0xB4E1D3FF,
            success_color_10 = 0xDEEDE8FF,

            // Gray colors (same as light theme)
            gray_color_1 = 0xF3F3F3FF,
            gray_color_2 = 0xEEEEEEFF,
            gray_color_3 = 0xE8E8E8FF,
            gray_color_4 = 0xDDDDDDFF,
            gray_color_5 = 0xC6C6C6FF,
            gray_color_6 = 0xA6A6A6FF,
            gray_color_7 = 0x8B8B8BFF,
            gray_color_8 = 0x777777FF,
            gray_color_9 = 0x5E5E5EFF,
            gray_color_10 = 0x4B4B4BFF,
            gray_color_11 = 0x393939FF,
            gray_color_12 = 0x2C2C2CFF,
            gray_color_13 = 0x242424FF,
            gray_color_14 = 0x181818FF,

            // Font colors
            font_white_1 = 0xFFFFFFE6,   // rgba(255,255,255,0.9)
            font_white_2 = 0xFFFFFF8C,  // rgba(255,255,255,0.55)
            font_white_3 = 0xFFFFFF59,  // rgba(255,255,255,0.35)
            font_white_4 = 0xFFFFFF38,  // rgba(255,255,255,0.22)
            font_gray_1 = 0x000000E6,   // rgba(0,0,0,0.9)
            font_gray_2 = 0x00000099,   // rgba(0,0,0,0.6)
            font_gray_3 = 0x00000066,   // rgba(0,0,0,0.4)
            font_gray_4 = 0x00000042,   // rgba(0,0,0,0.26)

            // Semantic colors
            brand_color = brand_color_8,
            warning_color = warning_color_5,
            error_color = error_color_6,
            success_color = success_color_5,
            brand_color_hover = brand_color_7,
            brand_color_focus = brand_color_2,
            brand_color_active = brand_color_9,
            brand_color_disabled = brand_color_3,
            brand_color_light = brand_color_1,
            brand_color_light_hover = brand_color_2,
            warning_color_hover = warning_color_4,
            warning_color_focus = warning_color_2,
            warning_color_active = warning_color_6,
            warning_color_disabled = warning_color_3,
            warning_color_light = warning_color_1,
            warning_color_light_hover = warning_color_2,
            error_color_hover = error_color_5,
            error_color_focus = error_color_2,
            error_color_active = error_color_7,
            error_color_disabled = error_color_3,
            error_color_light = error_color_1,
            error_color_light_hover = error_color_2,
            success_color_hover = success_color_4,
            success_color_focus = success_color_2,
            success_color_active = success_color_6,
            success_color_disabled = success_color_3,
            success_color_light = success_color_1,
            success_color_light_hover = success_color_2,

            // UI colors
            mask_active = 0x00000066,       // rgba(0,0,0,0.4)
            mask_disabled = 0x00000099,     // rgba(0,0,0,0.6)
            bg_color_page = gray_color_14,
            bg_color_container = gray_color_13,
            bg_color_container_hover = gray_color_12,
            bg_color_container_active = gray_color_10,
            bg_color_container_select = gray_color_9,
            bg_color_secondary_container = gray_color_12,
            bg_color_secondary_container_hover = gray_color_11,
            bg_color_secondary_container_active = gray_color_9,
            bg_color_component = gray_color_11,
            bg_color_component_hover = gray_color_10,
            bg_color_component_active = gray_color_9,
            bg_color_secondary_component = gray_color_10,
            bg_color_secondary_component_hover = gray_color_9,
            bg_color_secondary_component_active = gray_color_8,
            bg_color_component_disabled = gray_color_12,
            bg_color_special_component = 0x00000000, // transparent
            text_color_primary = font_white_1,
            text_color_secondary = font_white_2,
            text_color_placeholder = font_white_3,
            text_color_disabled = font_white_4,
            text_color_anti = 0xFFFFFFFF,
            text_color_brand = brand_color_8,
            text_color_link = brand_color_8,
            border_level_1_color = gray_color_11,
            component_stroke = gray_color_11,
            border_level_2_color = gray_color_9,
            component_border = gray_color_9,
            table_shadow_color = 0x0000008C, // rgba(0,0,0,0.55)
            scrollbar_color = 0xFFFFFF1A,    // rgba(255,255,255,0.1)
            scrollbar_hover_color = 0xFFFFFF4D, // rgba(255,255,255,0.3)
            scroll_track_color = 0x333333FF
        };
    }

    std::string ColorsEnumToHexStr(uint32_t color);

    namespace Common
    {
        // Common variables defined in :root
        enum class FontFamily : uint32_t
        {
            Regular = 0, // "pingfang sc", "microsoft yahei", "arial regular"
            Medium = 1   // "pingfang sc", "microsoft yahei", "arial medium"
        };

        // Font sizes
        enum class FontSize : uint8_t
        {
            LinkSmall = 12,
            LinkMedium = 14,
            LinkLarge = 16,
            MarkSmall = 12,
            MarkMedium = 14,
            BodySmall = 12,
            BodyMedium = 14,
            BodyLarge = 16,
            TitleSmall = 14,
            TitleMedium = 16,
            TitleLarge = 20,
            HeadlineSmall = 24,
            HeadlineMedium = 28,
            HeadlineLarge = 36,
            DisplayMedium = 48,
            DisplayLarge = 64
        };

        // Line heights
        enum class LineHeight : uint8_t
        {
            LinkSmall = 20,
            LinkMedium = 22,
            LinkLarge = 24,
            MarkSmall = 20,
            MarkMedium = 22,
            BodySmall = 20,
            BodyMedium = 22,
            BodyLarge = 24,
            TitleSmall = 22,
            TitleMedium = 24,
            TitleLarge = 28,
            HeadlineSmall = 32,
            HeadlineMedium = 36,
            HeadlineLarge = 44,
            DisplayMedium = 56,
            DisplayLarge = 72
        };

        // Radius sizes
        enum class Radius : uint8_t
        {
            Small = 2,
            Default = 3,
            Medium = 6,
            Large = 9,
            ExtraLarge = 12,
            Round = 255, // Special value for round
            Circle = 254 // Special value for circle
        };

        // Size system
        enum class Size : uint8_t
        {
            S1 = 2,
            S2 = 4,
            S3 = 6,
            S4 = 8,
            S5 = 12,
            S6 = 16,
            S7 = 20,
            S8 = 24,
            S9 = 28,
            S10 = 32,
            S11 = 36,
            S12 = 40,
            S13 = 48,
            S14 = 56,
            S15 = 64,
            S16 = 72
        };

        // Component sizes
        enum class CompSize : uint8_t
        {
            XXXS = Size::S6,
            XXS = Size::S7,
            XS = Size::S8,
            S = Size::S9,
            M = Size::S10,
            L = Size::S11,
            XL = Size::S12,
            XXL = Size::S13,
            XXXL = Size::S14,
            XXXXL = Size::S15,
            XXXXXL = Size::S16
        };

        // Padding and margin sizes
        enum class Padding : uint8_t
        {
            PopS = Size::S2,
            PopM = Size::S3,
            PopL = Size::S4,
            PopXL = Size::S5,
            PopXXL = Size::S6,

            LRXXS = Size::S1,
            LRXS = Size::S2,
            LRS = Size::S4,
            LRM = Size::S5,
            LRL = Size::S6,
            LRXL = Size::S8,
            LRXXL = Size::S10,

            TBXXS = Size::S1,
            TBXS = Size::S2,
            TBS = Size::S4,
            TBM = Size::S5,
            TBL = Size::S6,
            TBXL = Size::S8,
            TBXXL = Size::S10
        };

        enum class Margin : uint8_t
        {
            XXXS = Size::S1,
            XXS = Size::S2,
            S = Size::S4,
            M = Size::S5,
            L = Size::S6,
            XL = Size::S7,
            XXL = Size::S8,
            XXXL = Size::S10,
            XXXXL = Size::S12
        };
    }
}
